<?php

namespace app\api\controller;

use app\common\exception\BusinessException;
use think\response\Json;

class ActivationCode extends Base
{

    /**
     * 确认激活
     * @throws BusinessException
     */
    public function confirm(): Json
    {
        // 请求参数
        $param = $this->request->param();

        // 验证规则
        $rule = [
            'code' => 'require',
        ];

        // 错误信息
        $errMsg = [
            'code.require' => '激活码不得为空',
        ];

        // 数据验证
        $valRel = $this->validate($param, $rule, $errMsg);
        if ($valRel !== true) {
            throw new BusinessException($valRel, 0);
        }

        // 提交数据
        app(\app\api\logic\ActivationCode::class)->confirm($param);

        // 返回
        return $this->response();
    }

}

